package co.th.helper.jdbc.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import co.th.helper.jdbc.RowMapper;
import co.th.helper.model.Province;

public class ProvinceRowMapper extends RowMapper<Province> {

	@Override
	public Province mapRow(ResultSet resultSet) throws SQLException {
		Province model = new Province();

		if (isThere(resultSet, "province_id")) {
			model.setProvinceId(resultSet.getBigDecimal("province_id"));
		}

		if (isThere(resultSet, "province_name_th")) {
			model.setProvinceNameTH(resultSet.getString("province_name_th"));
		}

		if (isThere(resultSet, "province_name_en")) {
			model.setProvinceNameEn(resultSet.getString("province_name_en"));
		}

		if (isThere(resultSet, "create_by")) {
			model.setCreateBy(resultSet.getString("create_by"));
		}

		if (isThere(resultSet, "create_date")) {
			model.setCreateDate(resultSet.getDate("create_date"));
		}

		if (isThere(resultSet, "update_by")) {
			model.setUpdateBy(resultSet.getString("update_by"));
		}

		if (isThere(resultSet, "update_date")) {
			model.setUpdateDate(resultSet.getDate("update_date"));
		}

		return model;
	}

}
